/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author TANGQUOCTUAN
 */
@Entity
@Table(name = "ResTable", catalog = "TUNGA", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "ResTable.findAll", query = "SELECT r FROM ResTable r"),
    @NamedQuery(name = "ResTable.findByTableNumber", query = "SELECT r FROM ResTable r WHERE r.tableNumber = :tableNumber"),
    @NamedQuery(name = "ResTable.findByNoSeats", query = "SELECT r FROM ResTable r WHERE r.noSeats = :noSeats"),
    @NamedQuery(name = "ResTable.findByDescription", query = "SELECT r FROM ResTable r WHERE r.description = :description"),
    @NamedQuery(name = "ResTable.findByPicture", query = "SELECT r FROM ResTable r WHERE r.picture = :picture")})
public class ResTable implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "TableNumber", nullable = false)
    private Integer tableNumber;
    @Basic(optional = false)
    @Column(name = "NoSeats", nullable = false)
    private int noSeats;
    @Basic(optional = false)
    @Column(name = "Description", nullable = false, length = 1073741823)
    private String description;
    @Column(name = "Picture", length = 300)
    private String picture;
    @JoinColumn(name = "ResID", referencedColumnName = "ResID")
    @ManyToOne
    private Restaurants restaurants;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "resTable")
    private List<BookTableDetails> bookTableDetailsList;

    public ResTable() {
    }

    public ResTable(Integer tableNumber) {
        this.tableNumber = tableNumber;
    }

    public ResTable(int noSeats, String description, String picture) {
        this.noSeats = noSeats;
        this.description = description;
        this.picture= picture;
    }

    public Integer getTableNumber() {
        return tableNumber;
    }

    public void setTableNumber(Integer tableNumber) {
        this.tableNumber = tableNumber;
    }

    public int getNoSeats() {
        return noSeats;
    }

    public void setNoSeats(int noSeats) {
        this.noSeats = noSeats;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    public Restaurants getRestaurants() {
        return restaurants;
    }

    public void setRestaurants(Restaurants restaurants) {
        this.restaurants = restaurants;
    }

    public List<BookTableDetails> getBookTableDetailsList() {
        return bookTableDetailsList;
    }

    public void setBookTableDetailsList(List<BookTableDetails> bookTableDetailsList) {
        this.bookTableDetailsList = bookTableDetailsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tableNumber != null ? tableNumber.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ResTable)) {
            return false;
        }
        ResTable other = (ResTable) object;
        if ((this.tableNumber == null && other.tableNumber != null) || (this.tableNumber != null && !this.tableNumber.equals(other.tableNumber))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.ResTable[tableNumber=" + tableNumber + "]";
    }

}
